﻿//获取地址栏上级模块参数
var rid = null;
str = window.location.href;
pos = str.indexOf("?pid=");
if (pos > 0) {
    rid = str.substring(pos + 5);
}
var m_index = 0;
var myarr;

//请求二级权限
function getSecondRank() {
    var url = "../Handler.ashx";
    var pars = "act=GetSecondRank&rid="+rid;
    Ajax(url, pars, "get", getSecondRank_Complete, getSecondRank_Wait, true);
    url = null;
    pars = null;
}

function getSecondRank_Complete(req) {
    if (req.responseText == "false") {
        document.write("<span style='color:#ff0000; font-size:12px; margin:10px;'>菜单加载失败</span>");
    }
    else if (req.responseText == "") {
        document.write("<span style='color:#ff0000; font-size:12px; margin:10px;'>无任何权限</span>");
    }
    else if (req.responseText == "uid_out") {
        //document.write("<span style='color:#ff0000; font-size:12px; margin:10px;'>用户状态丢失</span>");
        parent.location = "../index.html";
    }
    else {
        var ranklist = req.responseText.split("|");
        var tempstr = "";
        myarr = new Array(ranklist.length);
        for (var i = 0; i < ranklist.length; i++) {
            tempstr += "<li><h4><span onclick='setNV2(" + ranklist[i].split(",")[0] + ",\"" + ranklist[i].split(",")[1] + "\")'>" + ranklist[i].split(",")[1] + "</span></h3><div class='content' id='m_" + ranklist[i].split(",")[0] + "'></div></li>";
            myarr[i] = ranklist[i].split(",")[0];
            if(i==0)setNV2(ranklist[i].split(",")[1],ranklist[i].split(",")[1]);
        }
        $("rolin").innerHTML = tempstr;
        
        getThirdRank();//获取三级权限
        ranklist = null;
        tempstr = null;
    }
}

function getSecondRank_Wait() {
    
}


//请求三级权限
function getThirdRank() {
    var url = "../Handler.ashx";
    var pars = "act=GetThirdRank&rid=" + myarr[m_index];
    Ajax(url, pars, "get", getThirdRank_Complete, getThirdRank_Wait, true);
    url = null;
    pars = null;
}

function getThirdRank_Complete(req) {
    if (req.responseText == "false") {
        $("m_" + myarr[m_index]).innerHTML = "<div style='color:#ff0000; font-size:12px; margin:10px;'>菜单加载失败</div>";
    }
    else if (req.responseText == "") {
        $("m_" + myarr[m_index]).innerHTML = "<div style='color:#ff0000; font-size:12px; margin:10px;'>无任何权限</div>";
    }
    else if (req.responseText == "uid_out") {
        $("m_" + myarr[m_index]).innerHTML = "<div style='color:#ff0000; font-size:12px; margin:10px;'>用户状态丢失</div>";
        parent.location = "../index.html";
    }
    else {
        var ranklist_ = req.responseText.split("|");
        var tempstr_ = "";
        for (var i = 0; i < ranklist_.length; i++) {
            tempstr_ += "<DIV><a href='" + ranklist_[i].split(",")[2]+"' onmouseover='status=\"\"; return true;' onmousedown='status=\"\"; return true;' onmouseup='status=\"\"; return true;' target='main' onfocus='this.blur();status=\"\"; return true;' onclick='setNV3(\"" + ranklist_[i].split(",")[1] + "\")'>" + ranklist_[i].split(",")[1] + "</a></DIV>";
        }
        $("m_" + myarr[m_index]).innerHTML = tempstr_;
        ranklist_=null;
        tempstr_ = null;
    }
    m_index++;
    if (m_index == myarr.length) {
        rolinTab('rolin');
    }
    else {
        getThirdRank()
    }
}

function getThirdRank_Wait() {

}

function setNV2(index,str) {
    parent.$("navigation2").innerHTML = "&nbsp;-&nbsp;" + str;
    parent.$("navigation3").innerHTML = "";
    if(str == "公告管理"){
        parent.$("main").src = "Notice/Notice_Main.aspx";
    }
    else if(str == "项目申报" && index==53){
        parent.$("main").src = "Items/Items_List.aspx";
    }
    else if(str == "项目立项" && index==54){
        parent.$("main").src = "Items/Items_ConfirmList.aspx";
    }
    else if(str == "经费到账" && index==55){
        parent.$("main").src = "Items/Items_IList.aspx";
    }
    else if(str == "经费支出" && index==56){
        parent.$("main").src = "Items/Items_OList.aspx";
    }
    else if(str == "项目中检" && index==57){
        parent.$("main").src = "Items/Items_SList.aspx";
    }
    else if(str == "项目结项" && index==58){
        parent.$("main").src = "Items/Items_EList.aspx";
    }
    else if(str == "延期" && index==59){
        parent.$("main").src = "Items/Items_DelayList.aspx";
    }
    else if(str == "终止" && index==60){
        parent.$("main").src = "Items/Items_PuaseList.aspx";
    }
    else if(str == "论文" && index==61){
        parent.$("main").src = "Results/Thesis_List.aspx";
    }
    else if(str == "研究报告" && index==62){
        parent.$("main").src = "Results/Report_List.aspx";
    }
    else if(str == "著作&教材" && index==63){
        parent.$("main").src = "Results/Iiterature_List.aspx";
    }
    else if(str == "获奖" && index==64){
        parent.$("main").src = "Results/Awards_List.aspx";
    }
    else if(str == "鉴定" && index==65){
        parent.$("main").src = "Results/Appraise_List.aspx";
    }
    else if(str == "专利" && index==66){
        parent.$("main").src = "Results/Patent_List.aspx";
    }
    else if(str == "作品&产品" && index==199){
        parent.$("main").src = "Results/Art_List.aspx";
    }
    else if(str == "成果转化" && index==200){
        parent.$("main").src = "Results/Achieve_List.aspx";
    }
    else if(str == "主办会议" && index==67){
        parent.$("main").src = "Activity/MainMeeting_List.aspx";
    }
    else if(str == "学术讲座" && index==68){
        parent.$("main").src = "Activity/Learn_List.aspx";
    }
    else if(str == "参加会议" && index==69){
        parent.$("main").src = "Activity/AttendMeeting_List.aspx";
    }
    else if(str == "刊物" && index==70){
        parent.$("main").src = "Publication/Publication_List.aspx";
    }
    else if(str == "科技期刊"){
        parent.$("main").src = "Publication/Periodical_List.aspx";
    }
    else if(str == "科研机构" && index==52){
        parent.$("main").src = "Institution/Unit_List.aspx";
    }
    else if(str == "科研人员" && index==47){
        parent.$("main").src = "Personnel/Personnel_List.aspx";
    }
    else if(str == "用户管理" && index==48){
        parent.$("main").src = "Personnel/Role_List.aspx";
    }
    else if(str == "人员维护" && index==50){
        parent.$("main").src = "Personnel/Transfer_Department.aspx";
    }
    else if(str == "科研考核批次"){
        parent.$("main").src = "Score/Items_BatchList.aspx";
    }
    else if(str == "科研考核评定"){
        parent.$("main").src = "Score/Items_ScoreList1.aspx";
    }
    else if(str == "科研考核查询"){
        parent.$("main").src = "Score/Items_ScoreSearch_Person.aspx";
    }
    else if(str == "教研考核批次"){
        parent.$("main").src = "Score/Items_BatchList3.aspx";
    }
    else if(str == "教研考核评定"){
        parent.$("main").src = "Score/Items_ScoreList15_3.aspx";
    }
    else if(str == "教研考核查询"){
        parent.$("main").src = "Score/Items_ScoreSearch_Person3.aspx";
    }
    else if(str == "质量工程考核批次"){
        parent.$("main").src = "Score/Items_BatchList2.aspx";
    }
    else if(str == "质量工程考核评定"){
        parent.$("main").src = "Score/Items_ScoreList15_2.aspx";
    }
    else if(str == "质量工程考核查询"){
        parent.$("main").src = "Score/Items_ScoreSearch_Person2.aspx";
    }
    else if(str == "科研统计"){
        parent.$("main").src = "Statis/Statis_List.aspx";
    }
    else if(str == "项目成果查询"){
        parent.$("main").src = "Research/Items_ReportSearch.aspx";
    }
    else if(str == "科研项目" && index==72){
        parent.$("main").src = "Research/Items_Forms.aspx";
    }
    else if(str == "科研成果" && index==395){
        parent.$("main").src = "Research/Thesis_Forms.aspx";
    }
    else if(str == "学术活动" && index==399){
        parent.$("main").src = "Research/MainMeeting_Forms.aspx";
    }
    else if(str == "质量工程" && index==400){
        parent.$("main").src = "Research/Teach_Forms.aspx";
    }
    else if(str == "教研项目" && index==469){
        parent.$("main").src = "Research/Faculty_Forms.aspx";
    }
    else if(str == "人员管理" && index==401){
        parent.$("main").src = "Research/Personnel_Forms.aspx";
    }
    else if(str == "项目申报" && index==74){
        parent.$("main").src = "Teach/Items_List.aspx";
    }
    else if(str == "项目立项" && index==75){
        parent.$("main").src = "Teach/Items_ConfirmList.aspx";
    }
    else if(str == "经费到账" && index==76){
        parent.$("main").src = "Teach/Items_IList.aspx";
    }
    else if(str == "经费支出" && index==77){
        parent.$("main").src = "Teach/Items_OList.aspx";
    }
    else if(str == "项目中检" && index==78){
        parent.$("main").src = "Teach/Items_SList.aspx";
    }
    else if(str == "项目结项" && index==79){
        parent.$("main").src = "Teach/Items_EList.aspx";
    }
    else if(str == "项目延期" && index==80){
        parent.$("main").src = "Teach/Items_DelayList.aspx";
    }
    else if(str == "项目终止" && index==81){
        parent.$("main").src = "Teach/Items_PuaseList.aspx";
    }
    else if(str == "量化考核标准"){
        parent.$("main").src = "Base/Quantitative_List.aspx";
    }
    else if(str == "项目申报" && index==446){
        parent.$("main").src = "Faculty/Items_List.aspx";
    }
    else if(str == "项目立项" && index==447){
        parent.$("main").src = "Faculty/Items_ConfirmList.aspx";
    }
    else if(str == "经费到账" && index==448){
        parent.$("main").src = "Faculty/Items_IList.aspx";
    }
    else if(str == "经费支出" && index==449){
        parent.$("main").src = "Faculty/Items_OList.aspx";
    }
    else if(str == "项目中检" && index==450){
        parent.$("main").src = "Faculty/Items_SList.aspx";
    }
    else if(str == "项目结项" && index==451){
        parent.$("main").src = "Faculty/Items_EList.aspx";
    }
    else if(str == "延期" && index==452){
        parent.$("main").src = "Faculty/Items_DelayList.aspx";
    }
    else if(str == "终止" && index==453){
        parent.$("main").src = "Faculty/Items_PuaseList.aspx";
    }
}

function setNV3(str) {
    parent.$("navigation3").innerHTML = "&nbsp;-&nbsp;" + str;
}
//获取二级权限
getSecondRank();
